﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.Cfg;
using NHibernate.Util;


namespace Bussiness.Utilities
{
    class DmNamingStrategy : INamingStrategy
    {
        public string ClassToTableName(string className)
        {
            return "DM_" + StringHelper.Unqualify(className).ToUpper();
        }

        public string PropertyToColumnName(string propertyName)
        {
            return StringHelper.Unqualify(propertyName).ToUpper();
        }

        public string TableName(string tableName)
        {
            return "DM_" + StringHelper.Unqualify(tableName).ToUpper();
        }

        public string ColumnName(string columnName)
        {
            return StringHelper.Unqualify(columnName).ToUpper();
        }

        public string PropertyToTableName(string className, string propertyName)
        {
            return "DM_" + ClassToTableName(className) + "_" + PropertyToColumnName(propertyName);
        }

        public string LogicalColumnName(string columnName, string propertyName)
        {
            if (StringHelper.IsEmpty(columnName))
            {
                return PropertyToColumnName(propertyName);
            }

            return ColumnName(columnName);
        }
    }
}
